package com.example.myblog.mapper;

import com.example.myblog.entity.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Insert("insert into userinfo(username, password, email) values (#{username}, #{password},#{email})")
    int register(UserInfo userInfo);//注册

    @Select("select * from userinfo where username = #{username}")
    UserInfo getUserByName(String username);//通过用户名查看用户信息

    @Select("select * from userinfo where id = #{id}")
    UserInfo getUserById(Integer id);//通过用户id查看用户信息

    @Select("select * from userinfo where email = #{email}")
    UserInfo getUserByEmail(String email);//通过用户id查看用户信息

    @Update("update userinfo set photo = #{photoPath} where id = #{id}")
    int updatePhotoById(Integer id, String photoPath);

    @Update("update userinfo set username = #{username},introduction = #{introduction}," +
            "age = #{age}, address = #{address} where id = #{id}")
    int update(UserInfo userInfo);
}
